﻿using CommonFunction;
using MyWPF.StaticData;
using MyWPF.Views.Setting;
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace MyWPF.ViewModel.Setting
{
    public class VM_SetWindow : BaseViewModel
    {
        public VM_SetWindow()
        {
            _close = new DelegateCommand<object>(_Close);
            _min = new DelegateCommand<object>(_Min);
            _moveWindow = new DelegateCommand<object>(_MoveWindow);
            _loadedWindow = new DelegateCommand<object>(_LoadedWindow);
            _page_Nomal = new DelegateCommand<object>(_Page_Nomal);
            _page_Color = new DelegateCommand<object>(_Page_Color);
            _page_OPC = new DelegateCommand<object>(_Page_OPC);
            StaticModels.setWindow_Nomal = new SetWindow_Nomal();
            Content = StaticModels.setWindow_Nomal;
        }
        #region 基础：前端事件
        /// <summary>
        /// 关闭窗口
        /// </summary>
        private ICommand _close;
        public ICommand Close
        {
            get { return _close; }
            set
            {
                _close = value;
                OnPropertyChanged("Close");
            }
        }
        private void _Close(object obj)
        {



            StaticModels.setWindow.Close();
        }
        /// <summary>
        /// 最小化窗口
        /// </summary>
        private ICommand _min;
        public ICommand Min
        {
            get { return _min; }
            set
            {
                _min = value;
                OnPropertyChanged("Min");
            }
        }
        private void _Min(object obj)
        {
            StaticModels.setWindow.WindowState = System.Windows.WindowState.Minimized;
        }

        /// <summary>
        /// 移动窗口
        /// </summary>
        private ICommand _moveWindow;
        public ICommand MoveWindow
        {
            get { return _moveWindow; }
            set
            {
                _moveWindow = value;
                OnPropertyChanged("MoveWindow");
            }
        }
        private void _MoveWindow(object obj)
        {
            StaticModels.setWindow.DragMove();
        }

        #endregion
        #region 基础：页面切换
        private UserControl _content;
        public UserControl Content
        {
            get { return _content; }
            set { SetProperty(ref _content, value); }
        }
        /// <summary>
        /// 切换到常规
        /// </summary>
        private ICommand _page_Nomal;
        public ICommand Page_Nomal
        {
            get { return _page_Nomal; }
            set
            {
                _page_Nomal = value;
                OnPropertyChanged("Page_Nomal");
            }
        }
        private void _Page_Nomal(object obj)
        {
            ExecutePage(SetPages.SetNomal);
        }
        /// <summary>
        /// 切换到主题
        /// </summary>
        private ICommand _page_Color;
        public ICommand Page_Color
        {
            get { return _page_Color; }
            set
            {
                _page_Color = value;
                OnPropertyChanged("Page_Color");
            }
        }
        private void _Page_Color(object obj)
        {
            ExecutePage(SetPages.SetColor);
        }
        /// <summary>
        /// 切换到OPC
        /// </summary>
        private ICommand _page_OPC;
        public ICommand Page_OPC
        {
            get { return _page_OPC; }
            set
            {
                _page_OPC = value;
                OnPropertyChanged("Page_OPC");
            }
        }
        private void _Page_OPC(object obj)
        {
            ExecutePage(SetPages.SetOPC);
        }


        public enum SetPages
        {
            SetNomal, SetColor, SetOPC
        }
        public void ExecutePage(SetPages page)
        {
            switch (page)
            {
                case SetPages.SetNomal:
                    StaticModels.setWindow_Nomal = new SetWindow_Nomal();
                    Content = StaticModels.setWindow_Nomal;
                    break;
                case SetPages.SetColor:
                    StaticModels.setWindow_Color = new SetWindow_Color();
                    Content = StaticModels.setWindow_Color;
                    break;
                case SetPages.SetOPC:
                    StaticModels.setWindow_OPC = new SetWindow_OPC();
                    Content = StaticModels.setWindow_OPC;
                    break;

            }
        }
        private void OnPropertyChanged(string v)
        {
            throw new NotImplementedException();
        }
        #endregion


        #region 事件绑定：界面Load事件
        /// <summary>
        /// 切换到常规
        /// </summary>
        private ICommand _loadedWindow;
        public ICommand LoadedWindow
        {
            get { return _loadedWindow; }
            set
            {
                _loadedWindow = value;
                OnPropertyChanged("LoadedWindow");
            }
        }
        private void _LoadedWindow(object obj)
        {
            ExecutePage(SetPages.SetNomal);
        }
        #endregion
        




    }



}
